package com.example.ui.contact.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.huashangapp.R;
import com.example.ui.contact.chat.PushMessageReceiver;


/**
 * 与我相关的列表适配器
 * @author Leone
 *
 */

public class MyListViewAdapter extends BaseAdapter{
	private LayoutInflater inflater;
	private List<String> items;
    private Context mContext;
    private TextView titleText;
	private String[] MyText = {"系统通知","提到我的","评论","赞"};
	private int[] MyimgArr = {R.drawable.notice,R.drawable.about,R.drawable.comment,
			R.drawable.praise};
	public MyListViewAdapter(Context mContext,TextView titleText){
		this.mContext = mContext;
		this.titleText = titleText;
		inflater = LayoutInflater.from(mContext);
		
	}

	@Override
	public int getCount() {
		return 4;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		convertView=null;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.item07_tab1_listview_item, null);
			holder = new Holder();
        	holder.img = (ImageView)convertView.findViewById(R.id.item_list_img);
			holder.text = (TextView) convertView.findViewById(R.id.item_list_text_title);
			holder.arrow = (ImageView)convertView.findViewById(R.id.item_list_img);
			holder.txNum = (TextView)convertView.findViewById(R.id.item_list_text_num);
        	convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
		titleText.setText("与我相关");
		holder.img.setBackgroundResource(MyimgArr[position]);
		holder.text.setText(MyText[position]);

			
			switch(position){
			case 0:
				if(PushMessageReceiver.MSG_NOTICE!=0){
					holder.txNum.setVisibility(View.VISIBLE);
					holder.txNum.setText(""+PushMessageReceiver.MSG_NOTICE); 						
				}else{
					holder.txNum.setVisibility(View.GONE);
				}

				break;
			case 1:
				//holder.txNum.setText(""+PushMessageReceiver.MSG_ME); 
				if(PushMessageReceiver.MSG_ME!=0){
					holder.txNum.setVisibility(View.VISIBLE);
					holder.txNum.setText(""+PushMessageReceiver.MSG_ME); 						
				}else{
					holder.txNum.setVisibility(View.GONE);
				}
				break;
			case 2:
				//holder.txNum.setText(""+PushMessageReceiver.MSG_COMMENT); 
				if(PushMessageReceiver.MSG_COMMENT!=0){
					holder.txNum.setVisibility(View.VISIBLE);
					holder.txNum.setText(""+PushMessageReceiver.MSG_COMMENT); 						
				}else{
					holder.txNum.setVisibility(View.GONE);
				}
				break;
			case 3:
				//holder.txNum.setText(""+PushMessageReceiver.MSG_FUNS); 
				if(PushMessageReceiver.MSG_FUNS!=0){
					holder.txNum.setVisibility(View.VISIBLE);
					holder.txNum.setText(""+PushMessageReceiver.MSG_FUNS); 						
				}else{
					holder.txNum.setVisibility(View.GONE);
				}
				break;
			}





		
		return convertView;
	}
	
	class Holder{
    	ImageView img;
    	TextView text;
    	ImageView arrow;
    	TextView txNum;
    }				
}